package com.example.mapper;

import com.example.pojo.Order;
import com.example.pojo.User;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.web.bind.annotation.PathVariable;
import tk.mybatis.mapper.common.Mapper;

import java.util.List;

/**
 * @Description:
 * @author: GaoPeng
 * @date: 2021/5/26 21:31
 */
public interface OrderMapper extends Mapper<Order> {

    @Insert("insert into `Order` (user_id,receiver,address,post_code,tel,pay_way,transfer_way,remark,product_id,seller_id" +
            ",create_time,amount) " +
            "values(#{user_id},#{receiver},#{address},#{post_code},#{tel},#{pay_way},#{transfer_way},#{remark}," +
            "#{product_id},#{seller_id},#{create_time},#{amount});")
    Integer insertOrder(Order order);

    @Select("select * from `Order` where user_id=#{user_id}")
    List<Order> selectAllByUser_id(Integer user_id);

    @Select("select * from `Order` where id=#{id}")
    Order selectById( Integer id);

    @Update("update `Order` set remark=#{remark} where product_id=#{id}")
    Integer tuihuo(@Param("remark") String remark,@Param("id") Integer id);

    @Update("update `Order` set `status`=#{status} where id=#{id}")
    Integer changeStatus(@Param("id")Integer id,@Param("status") Integer status);

    @Select("select `sta` from `Order` where id=#{id}")
    Integer selectStatus(Integer id);





}
